<template>
  <div class="app-container">
    <!-- 导航栏 -->
    <el-card style="margin-bottom: 15px; height: 30px" shadow="always" :body-style="{ padding: '0' }">
      <div style="display: flex; line-height: 25px">
        <h1
          v-for="(item, index) in navItems"
          :key="index"
          :class="{ DynamicCondition: isActive === index, spacing: index > 0 }"
          @click="clickToSwitch(index)"
          style="font-size: 15px; cursor: pointer"
        >
          {{ item }}
        </h1>
      </div>
    </el-card>
    <!-- 楦头入库单查询 -->
    <div v-show="isActive === 1" class="ProductionDynamic">
      <Find @Launchform="Launchform5" :OriginalFilter="{ static: true }" :searchImg="false" :formList="formList1" @findClicked="findData1" />

      <el-card style="margin-top: 15px" shadow="always" :body-style="{ padding: '5px' }">
        <div class="ProductionDynamicMainCardMainL">
          <div style="width: 70%" class="ProductionDynamicMainCardMainLeft">
            <h1 class="MainLeftCardH1">单据明细</h1>
            <Table
              @currentRow="currentRow"
              :isLoading="isLoading"
              @selectValChange="checkboxChange1"
              :tableData="LastDetailsQueryParms"
              :tableHeader="tableHeader2"
              :selection="false"
              :TableHeight="95"
            />
          </div>
        </div>
        <!-- 分页器 -->
      </el-card>
    </div>

    <!-- 楦头入库单建立 -->
    <div v-show="isActive === 0">
      <Find :OriginalFilter="{ static: true }" @clickNumber="clickNumber" :formList="formList" @findClicked="findData" @Launchform="Launchform" />

      <el-card style="margin-top: 15px" shadow="always" :body-style="{ padding: '5px' }">
        <div class="ProductionDynamicMainCardMain">
          <div class="ProductionDynamicMainCardMainLeft">
            <h1 class="MainLeftCardH1">
              查询资料
              <h6 style="margin-left: 15px; margin-top: 5px; color: red">ps:双击查看单据明细</h6>
            </h1>
            <Table
              :isLoading="isLoading1"
              @currentRow1="currentRow1"
              @currentRow="selectList"
              :tableData="LastIntoStorageQueryMethodsTableDate"
              :tableHeader="tableHeader"
              :TableHeight="93"
            />
            <PageModule @pageSizeChange="handleSizeChangeTk" @pageChange="handleCurrentChangeTk" :PageData="{ total }" />
          </div>
        </div>
      </el-card>
    </div>

    <el-dialog v-model="dialogVisible2" width="50%">
      <Find :OriginalFilter="{ static: true }" @Launchform="Launchform12" @findClicked="findClicked12" :searchImg="false" :formList="formList2" />
    </el-dialog>

    <el-dialog v-model="dialogVisible3" width="50%">
      <Find :OriginalFilter="{ static: true }" @Launchform="Launchform13" @findClicked="findClicked13" :searchImg="false" :formList="formList3" />
    </el-dialog>
  </div>
</template>
<script lang="ts">
import { defineComponent, ref, onMounted } from 'vue'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'LastStorage'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
import {
  latNoQuery,
  LastIntoStorageQuery,
  checkActive,
  deleteLstOutStore,
  VenderQuery,
  LastDetailsQuery,
  SeparateDeletion,
  VenderQuery1,
  addLastIntoStorage
} from '@/api/Control/FactoryControl/LastStorage'
import LoginWork from '@/utils/LoginWork'
import { ElMessage, ElMessageBox } from 'element-plus'
const buttonAcitve = ref(true)

const isLoading = ref(false)

const isLoading1 = ref(false)

const ubdateValue = ref(true)

const cutNoListANy = ref('')

// 楦头查询
const latNoQueryMethods = async () => {
  const result = await latNoQuery('')

  formList.value[3].selectOptions = EvaluatesTheArrayReturnValue(result.data)
  formList2.value[3].selectOptions = EvaluatesTheArrayReturnValue(result.data)
  formList1.value[6].selectOptions = EvaluatesTheArrayReturnValue(result.data)
}

// 修改
const checkboxChange1 = async () => {
  const result = await LoginWork.put<any, any>(
    `/bioDeptWrok/lastInUp`,
    Object.assign(
      {},
      {
        detail: LastDetailsQueryParms.value.map((item: any) => {
          item.lastNo1 = item.lastNo

          if (item.sizeType.selectValue === '左脚') {
            item.sizeType = 'L'
          } else if (item.sizeType.selectValue === '右脚') {
            item.sizeType = 'R'
          } else if (item.sizeType.selectValue === '全脚') {
            item.sizeType = 'F'
          } else {
            item.sizeType = item.sizeType.selectValue
          }

          return item
        })
      },
      listQuery.value || addLastIntoParms.value,
      { remark: remarkList.value }
    )
  )
  if (result.code === 200) {
    LastDetailsQueryMethods()
    JMessage.success('成功')
  } else {
    JMessage.error(result.message)
  }
}

const checkboxChange1Parms = ref<any>([])

// 新增
const addLastIntoParms = ref<any>({
  inOutType: '',
  lastNo: '',
  remark: '',
  slipDate: '',
  slipNo: '',
  slipType: '',
  stkName: '',
  stkNo: '',
  vendorName: '',
  vendorNo: ''
})

const detailList = ref({
  detail: [
    {
      lastNo1: '',
      sizeNo: '',
      sizeType: '',
      qty: ''
    }
  ]
})

const addLastIntoStorageMethods = async () => {
  cutNoListANy.value = addLastIntoParms.value.lastNo
  const result = await addLastIntoStorage(addLastIntoParms.value)
  if (result.code === 200) {
    LastDateList.value = result.message
    dialogVisible3.value = false
    LastDetailsQueryMethods()
    sliptNpList.value = result.message

    formList1.value[0].inputValue = result.message
    addLastIntoParms.value.slipNo = result.message
    clearFormList3()
    JMessage.success('成功')
  } else {
    JMessage.error(result.message)
  }
}

// 新增
const Launchform5 = (row: any) => {
  addLastIntoParms.value.slipDate = row[1].dateValue
  addLastIntoParms.value.inOutType = row[2].selectValue
  addLastIntoParms.value.stkName = row[3].selectValue.split(' ')[1]
  addLastIntoParms.value.stkNo = row[3].selectValue.split(' ')[0]
  addLastIntoParms.value.vendorName = row[4].selectValue.split(' ')[1]
  addLastIntoParms.value.vendorNo = row[4].selectValue.split(' ')[0]
  addLastIntoParms.value.remark = row[5].inputValue
  addLastIntoParms.value.lastNo = row[6].selectValue

  if (listQuery.value !== undefined) {
    listQuery.value.slipDate = row[1].dateValue
    listQuery.value.inOutType = row[2].selectValue
    listQuery.value.stkName = '荣阳楦头仓'
    listQuery.value.stkNo = 'BF001'

    listQuery.value.lastNo = row[6].selectValue
    remarkList.value = row[5].inputValue

    const vendorNo = row[4].selectValue // 假设 vendorNo 是 "LYM老义美"

    // 使用正则表达式匹配字母和汉字
    const match = vendorNo.match(/([A-Za-z]+)([\u4e00-\u9fa5]+)/)

    if (row[4] && row[4].selectValue && row[4].selectValue.includes(' ')) {
      listQuery.value.vendorName = row[4].selectValue.split(' ')[1]
      listQuery.value.vendorNo = row[4].selectValue.split(' ')[0]
    } else {
      listQuery.value.vendorName = match[1]
      listQuery.value.vendorNo = match[0]
    }
  }
}

const VenderQueryMethods1 = async () => {
  const result = await VenderQuery1()
  const NewArrayList = result.reduce((arr: any, item: any) => {
    if (item.ITEM_CODE && item.ITEM_NAME) {
      arr.push(item.ITEM_CODE + ' ' + item.ITEM_NAME)
    }
    return arr
  }, [])
  formList2.value[4].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
  formList1.value[3].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
}
const dialogVisible2 = ref(false)

const Launchform12 = (row: any) => {
  addLastIntoParms.value.slipDate = row[0].dateValue
  addLastIntoParms.value.inOutType = row[1].selectValue
  addLastIntoParms.value.vendorNo = row[2].selectValue.split(' ')[0]
  addLastIntoParms.value.vendorName = row[2].selectValue.split(' ')[1]
  addLastIntoParms.value.lastNo = row[3].selectValue
  addLastIntoParms.value.stkNo = row[4].selectValue.split(' ')[0]
  addLastIntoParms.value.stkName = row[4].selectValue.split(' ')[1]
  addLastIntoParms.value.remark = row[5].inputValue
  // addLastIntoParms.value.detail[0].lastNo1 = row[6].inputValue
  // addLastIntoParms.value.detail[0].sizeNo = row[7].inputValue
  // addLastIntoParms.value.detail[0].sizeType = row[8].selectValue
  // addLastIntoParms.value.detail[0].qty = row[9].inputValue
}

const findClicked12 = (cout: string) => {
  if (cout === '保存') {
    addLastIntoStorageMethods()
  }
  if (cout === '置空') {
    clearFormList2()
  }
}

const dialogVisible3 = ref(false)

const Launchform13 = (row: any) => {
  detailList.value.detail[0].lastNo1 = row[0].inputValue
  detailList.value.detail[0].sizeNo = row[1].inputValue
  detailList.value.detail[0].sizeType = row[2].selectValue
  detailList.value.detail[0].qty = row[3].inputValue
}

const findClicked13 = (cout: string) => {
  if (cout === '保存') {
    addLastIntoParms.value.detail = detailList.value.detail
    // LastDetailsQueryParms.value.push(addLastIntoParms.value.detail[0])

    // addLastIntoParms.value.detail = LastDetailsQueryParms.value.map((item: any) => {
    //   if (item.sizeType.options !== undefined) {
    //     item.sizeType = item.sizeType.selectValue
    //   }
    //   delete item.slipNo

    //   return item
    // })

    addLastIntoStorageMethods()
  }
  if (cout === '置空') {
    clearFormList3()
  }
}

const clearFormList3 = () => {
  formList3.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    // Add other conditions for different form item types
  })
}

const formList2 = ref([
  {
    type: 'dateSingle',
    dateLabel: '下单日期',
    dateValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 1,
        optionValue: '采购入库',
        optionLabel: '采购入库'
      },
      {
        optionKey: 2,
        optionValue: '开发入库',
        optionLabel: '开发入库'
      },
      {
        optionKey: 3,
        optionValue: '盘盈入库',
        optionLabel: '盘盈入库'
      }
    ],
    selectP: '订单类型'
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [],
    selectP: '厂商'
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [],
    selectP: '楦头'
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [],
    selectP: '仓库'
  },
  {
    type: 'input',
    inputPlaceholder: '备注',
    inputValue: ''
  },

  {
    type: 'input',
    inputPlaceholder: '单据明细->楦头号',
    inputValue: ''
  },

  {
    type: 'input',
    inputPlaceholder: '单据明细->号码',
    inputValue: ''
  },

  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 'F',
        optionValue: 'F',
        optionLabel: '全双'
      },
      {
        optionKey: 'L',
        optionValue: 'L',
        optionLabel: '左脚'
      },
      {
        optionKey: 'R',
        optionValue: 'R',
        optionLabel: '右脚'
      }
    ],
    selectP: '单据明细->单双脚'
  },

  {
    type: 'input',
    inputPlaceholder: '单据明细->数量',
    inputValue: ''
  },

  {
    type: 'button',
    checkboxLabel: '保存'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList3 = ref([
  {
    type: 'input',
    inputPlaceholder: '单据明细->楦头号',
    inputValue: ''
  },

  {
    type: 'input',
    inputPlaceholder: '单据明细->号码',
    inputValue: ''
  },

  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 'F',
        optionValue: 'F',
        optionLabel: '全双'
      },
      {
        optionKey: 'L',
        optionValue: 'L',
        optionLabel: '左脚'
      },
      {
        optionKey: 'R',
        optionValue: 'R',
        optionLabel: '右脚'
      }
    ],
    selectP: '单据明细->单双脚'
  },

  {
    type: 'input',
    inputPlaceholder: '单据明细->数量',
    inputValue: ''
  },

  {
    type: 'button',
    checkboxLabel: '保存'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const clearFormList2 = () => {
  formList2.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    if (item.type === 'date') {
      item.dateValue = ''
    }
    // Add other conditions for different form item types
  })
}

// 删除
const currentRow = (row: any) => {
  SeparateSlpNoParms.value = row.seqNo

  checkboxChange1Parms.value.map((item: any) => {
    item.sizeTypeOld = item.sizeType.selectValue === null ? '' : item.sizeType.selectValue
    return item
  })
}

const findData1 = (row: string) => {
  if (row === '删除') {
    handleCloseMateriaLKlc()
  }
  if (row === '增加明细') {
    LastDetailsQueryParms.value.push({
      lastNo: cutNoListANy.value,
      sizeNo: '',
      change: 'Y',
      disableConfirm: true,
      sizeType: {
        selectValue: '',
        options: [
          { value: '全脚', label: '全脚', item: '1' },
          { value: '左脚', label: '左脚', item: '2' },
          { value: '右脚', label: '右脚', item: '3' }
        ]
      },
      qty: '',
      slipNo: sliptNpList.value
    })
  }
  if (row === '增加') {
    addLastIntoStorageMethods()
  }
  if (row === '保存修改') {
    checkboxChange1()
  }
}

const SeparateSlpNo = ref('')

const SeparateSlpNoParms = ref('')

const handleCloseMateriaLKlc = () => {
  if (SeparateSlpNoParms.value === '') {
    JMessage.warning('请选择需要删除的数据')
  } else {
    ElMessageBox.confirm('确认要删除数据吗?')
      .then(async () => {
        SeparateDeletionMethods()
      })
      .catch(() => {})
  }
}

const SeparateDeletionMethods = async () => {
  const result = await SeparateDeletion(SeparateSlpNo.value, SeparateSlpNoParms.value)
  if (result.code === 200) {
    LastDetailsQueryMethods()
    SeparateSlpNoParms.value = ''
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

// 明细查询
const LastDateList = ref('')

const LastDetailsQueryParms = ref<any>([])

const remarkList = ref('')

const ActiveList = ref(false)
const ActiveList1 = ref(false)

const LastDetailsQueryMethods = async () => {
  isLoading.value = true
  const result = await LastDetailsQuery(LastDateList.value)
  checkboxChange1Parms.value = result.details
  if (result.details !== null) {
    if (ActiveList.value) {
      LastDetailsQueryParms.value = result.details.map((item: any) => {
        if (ActiveList.value) {
          item.change = 'Y'
          item.disableConfirm = true
          item.sizeType = {
            selectValue: item.sizeType,
            options: [
              { value: '全脚', label: '全脚', item: '1' },
              { value: '左脚', label: '左脚', item: '2' },
              { value: '右脚', label: '右脚', item: '3' }
            ]
          }
        }
        return item
      })
    } else {
      LastDetailsQueryParms.value = result.details
    }
  }
  if (ActiveList1.value) {
    formList1.value[0].inputValue = result.slipNo
    formList1.value[1].dateValue = result.slipDate
    formList1.value[2].selectValue = result.inOutType
    formList1.value[3].selectValue = result.stkNo + result.stkName
    formList1.value[4].selectValue = result.vendorNo + result.vendorName
    formList1.value[6].selectValue = result.lastNo
    formList1.value[7].inputValue = result.cfmFlag
    formList1.value[5].inputValue = result.remark
  }
  remarkList.value = result.remark
  isLoading.value = false
}

const sliptNpList = ref('')

// 双击查询
const listQuery = ref()
const currentRow1 = (row: any) => {
  if (row.cfmFlag === null) {
    cutNoListANy.value = row.lastNo
    ActiveList1.value = true
    ubdateValue.value = false
    isActive.value = 1
    sliptNpList.value = row.slipNo
    LastDateList.value = row.slipNo
    SeparateSlpNo.value = row.slipNo
    listQuery.value = row
    addLastIntoParms.value.slipDate = row.slipDate
    addLastIntoParms.value.slipNo = row.slipNo
    addLastIntoParms.value.inOutType = row.inOutType
    addLastIntoParms.value.vendorName = row.vendorName
    addLastIntoParms.value.vendorNo = row.vendorNo
    addLastIntoParms.value.lastNo = row.lastNo
    addLastIntoParms.value.stkName = row.stkName
    addLastIntoParms.value.stkNo = row.stkNo
    LastDetailsQueryMethods()
  } else {
    JMessage.error('已检核的数据不可修改')
  }
}

// 查询条件
const Launchform = (row: any) => {
  LastIntoStorageQueryParms.value.slipDateEnd = row[0].dateValue[1]
  LastIntoStorageQueryParms.value.slipDateStart = row[0].dateValue[0]
  LastIntoStorageQueryParms.value.inOutType = row[1].selectValue
  LastIntoStorageQueryParms.value.vendorNo = row[2].selectValue.split(' ')[1]
  LastIntoStorageQueryParms.value.lastNo = row[3].selectValue
  LastIntoStorageQueryParms.value.sizeNo = row[4].inputValue
  LastIntoStorageQueryParms.value.sizeType = row[5].selectValue
  LastIntoStorageQueryMethods()
}

const clickNumber = (num: number) => {
  LastIntoStorageQueryParms.value.cfmFlag = Number(num)
  LastIntoStorageQueryMethods()
}

// 厂商查询
const EvaluatesTheArrayReturnValue = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      optionKey: index,
      optionValue: item,
      optionLabel: item
    }
  })
}

const VenderQueryMethods = async () => {
  const result = await VenderQuery()
  const NewArrayList = result.reduce((arr: any, item: any) => {
    if (item.ITEM_CODE && item.ITEM_NAME) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.ITEM_CODE + ' ' + item.ITEM_NAME)
    }
    return arr
  }, [])

  formList.value[2].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
  formList2.value[2].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
  formList1.value[4].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
}

// 楦头入库单删除
const deleteLstOutStoreMethods = async () => {
  const result = await deleteLstOutStore(slipNoList.value)
  if (result.code === 200) {
    LastIntoStorageQueryMethods()
    slipNoList.value = ''
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

const handleCloseMateriaLKlc8 = () => {
  if (slipNoList.value === '') {
    JMessage.warning('请选择需要删除的数据')
  } else {
    ElMessageBox.confirm('确认要删除数据吗?')
      .then(async () => {
        deleteLstOutStoreMethods()
      })
      .catch(() => {})
  }
}

// 检核
const slipNoList = ref('')

const selectList = (row: any) => {
  slipNoList.value = row.slipNo
  LastDateList.value = row.slipNo
}

const checkActiveMethods = async () => {
  const result = await checkActive(slipNoList.value)
  if (result.code === 200) {
    LastIntoStorageQueryMethods()
    slipNoList.value = ''
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

// 入库单查询
const LastIntoStorageQueryParms = ref({
  cfmFlag: 1,
  inOutType: '',
  lastNo: '',
  pageNum: 1,
  pageSize: 40,
  sizeNo: '',
  sizeType: '',
  slipDateEnd: '',
  slipDateStart: '',
  vendorNo: ''
})

const LastIntoStorageQueryMethodsTableDate = ref([])

const LastIntoStorageQueryMethods = async () => {
  isLoading1.value = true
  const result = await LastIntoStorageQuery(LastIntoStorageQueryParms.value)
  LastIntoStorageQueryMethodsTableDate.value = result.dtos.map((item: any) => {
    if (item.cfmFlag !== 'Y') {
      ActiveList.value = true
    }
    return item
  })
  total.value = result.total
  if (result.dtos.length > 0) {
    // LastDateList.value = result.dtos[0].slipNo
    // SeparateSlpNo.value = result.dtos[0].slipNo
    // LastDetailsQueryMethods()
  }
  isLoading1.value = false
}

const total = ref(0)

const handleSizeChangeTk = (val: number) => {
  LastIntoStorageQueryParms.value.pageSize = val
  LastIntoStorageQueryMethods()
}

const handleCurrentChangeTk = (val: number) => {
  LastIntoStorageQueryParms.value.pageNum = val
  LastIntoStorageQueryMethods()
}

onMounted(() => {
  // LastIntoStorageQueryMethods()

  VenderQueryMethods()

  latNoQueryMethods()

  VenderQueryMethods1()
})

// 导航栏
const navItems = ref(['楦头入库单查询', '楦头入库单建立'])

// 导航栏状态
const isActive = ref(0)

const formList = ref([
  {
    type: 'date',
    dateLabel: '单据日期',
    dateValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 1,
        optionValue: '采购入库',
        optionLabel: '采购入库'
      },
      {
        optionKey: 2,
        optionValue: '开发入库',
        optionLabel: '开发入库'
      },
      {
        optionKey: 3,
        optionValue: '盘盈入库',
        optionLabel: '盘盈入库'
      }
    ],
    selectP: '入库类型'
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [],
    selectP: '厂商'
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [],
    selectP: '楦头'
  },
  {
    type: 'input',
    inputPlaceholder: '号码',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 1,
        optionValue: '全双',
        optionLabel: '全双'
      },
      {
        optionKey: 2,
        optionValue: '左脚',
        optionLabel: '左脚'
      },
      {
        optionKey: 3,
        optionValue: '右脚',
        optionLabel: '右脚'
      }
    ],
    selectP: '单双脚'
  },
  {
    type: 'radio',
    checkboxLabel: '已确认',
    checked: false,
    label: '1'
  },
  {
    type: 'radio',
    checkboxLabel: '未确认',
    checked: false,
    label: '0'
  },
  {
    type: 'button',
    checkboxLabel: '整单删除'
  },
  {
    type: 'button',
    checkboxLabel: '检核'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  },
  {
    type: 'button',
    checkboxLabel: '打印入库单'
  }
])

const formList1 = ref([
  {
    type: 'input1',
    inputPlaceholder: '请输入单据号',
    inputValue: '',
    inputDisabled: true
  },
  {
    type: 'dateSingle',
    dateLabel: '单据日期',
    dateValue: ''
  },

  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 1,
        optionValue: '采购入库',
        optionLabel: '采购入库'
      },
      {
        optionKey: 2,
        optionValue: '开发入库',
        optionLabel: '开发入库'
      },
      {
        optionKey: 3,
        optionValue: '盘盈入库',
        optionLabel: '盘盈入库'
      }
    ],
    selectP: '入库类型'
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [],
    selectP: '仓库'
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [],
    selectP: '厂商'
  },

  {
    type: 'input',
    inputPlaceholder: '备注',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectLabel: '',
    selectOptions: [],
    selectP: '楦头号'
  },
  {
    type: 'input',
    inputLabel: '检核标记',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '取楦头号码'
  },
  {
    type: 'button',
    checkboxLabel: '取订购单资料'
  },
  {
    type: 'button',
    checkboxLabel: '增加',
    disabled: buttonAcitve
  },
  {
    type: 'button',
    checkboxLabel: '增加明细'
  },
  {
    type: 'button',
    checkboxLabel: '删除'
  },
  {
    type: 'button',
    checkboxLabel: '保存修改'
  }
])

const findData = (data: string) => {
  switch (data) {
    case '检核': {
      if (slipNoList.value === '') {
        JMessage.warning('请选择需要检核的数据')
      } else {
        checkActiveMethods()
      }
      break
    }
    case '整单删除': {
      if (slipNoList.value === '') {
        JMessage.warning('请选择需要删除的数据')
      } else {
        handleCloseMateriaLKlc8()
      }
      break
    }
    case '置空': {
      clearFormList1()
      break
    }
  }
}

const clearFormList1 = () => {
  formList.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    if (item.type === 'date') {
      item.dateValue = ''
    }
    // Add other conditions for different form item types
  })
}

const clearFormList6 = () => {
  formList1.value.forEach((item) => {
    item.inputValue = ''
    item.selectValue = ''
    item.dateValue = ''
  })
}

// 表格数据

const tableHeader = ref([
  {
    label: '单据号',
    prop: 'slipNo',
    change: true
  },
  {
    label: '单据日期',
    prop: 'slipDate'
  },
  {
    label: '入库类型',
    prop: 'inOutType'
  },
  {
    label: '仓库',
    prop: 'stkName'
  },
  {
    label: '厂商',
    prop: 'vendorName'
  },
  {
    label: '楦头号',
    prop: 'lastNo'
  },
  {
    label: '号码',
    prop: 'sizeNo'
  },
  {
    label: '单双脚',
    prop: 'sizeType',
    change: true
  },
  {
    label: '数量',
    prop: 'qty'
  },
  {
    label: '检核',
    prop: 'cfmFlag',
    change: true
  }
])

// 表格数据

const tableHeader2 = ref([
  {
    label: '楦头号',
    prop: 'lastNo',
    change: true
  },
  {
    label: '号码',
    prop: 'sizeNo'
    // change: true
  },
  {
    label: '单双脚',
    prop: 'sizeType',
    type: 'select'
  },
  {
    label: '数量',
    prop: 'qty'
  }
])

//点击切换
const clickToSwitch = (index: number) => {
  isActive.value = index
  buttonAcitve.value = true
  if (index === 1) {
    buttonAcitve.value = false
    ubdateValue.value = true
    LastDetailsQueryParms.value = []
    addLastIntoParms.value.slipNo = ''
    clearFormList6()
  }
}
</script>

<style lang="less" scoped>
.H1Size {
  font-size: 16px;
}

.bottom {
  float: right;
}

.DynamicCondition {
  color: #f89027;
  border-bottom: 2px solid #f89027;
}

.spacing {
  margin-left: 15px;
  /* 根据需要调整间距大小 */
}

.save {
  color: black;
  border: 1px solid #e7e7e7;
  background: #e7e7e7;
}

.ProductionDynamicMainCardMainLeft {
  width: 70%;
}

.MainLeftCardH1 {
  font-size: 20px;
  display: flex;
}
</style>
